export default function resumeListReducer(resumeList, {type,...payload}) {
    switch (type) {
        case 'update':{
            const {id,content,title} = payload
            return resumeList.map(item=>{
                if(item.id === id){
                    let newItem = {...item}
                    content && (newItem = {...newItem,content})
                    title && (newItem = {...newItem,title})
                    return {...newItem}
                }else{
                    return item
                }
            })
        }
        case 'delete':{
            const {id} = payload
            return resumeList.filter(item=>item.id !== id)
        }
        case 'add':{
            return [...resumeList,{...payload}]  
        }
        case 'reset':{
            const {result} = payload
            return [...result]
        }
    }
}